package com.ymatou.iapi.godmch.testcase;

import java.util.List;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.godmch.parameter.createIndepMchBean;
import com.ymatou.iapi.godmch.parameter.getMchMemberExemptConfigBean;
import com.ymatou.iapi.godmch.service.createIndepMchCall;
import com.ymatou.iapi.godmch.service.getMchMemberExemptConfigCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.database.model.godmch.mch_configExample;
import com.ymttest.database.model.godmch.mch_member_exemptExample;
import com.ymttest.database.sqlwapper.godmch.mch_configWapper;
import com.ymttest.database.sqlwapper.godmch.mch_member_exemptWapper;
/**
*查询商户会员豁免配置
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_getMchMemberExemptConfig{
	private static getMchMemberExemptConfigBean bean;
	private static getMchMemberExemptConfigCall call;
	
	mch_member_exemptWapper memberWapper;
	mch_member_exemptExample memberExample;
	
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("查询商户会员豁免配置");
	}

	@Before
	public void caseUp() {
		bean=new getMchMemberExemptConfigBean();
		call=new getMchMemberExemptConfigCall();
		
		memberWapper=new mch_member_exemptWapper();
		memberExample=new mch_member_exemptExample();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getMchMemberExemptConfig_001() {
		Logger.start(true,"查询商户会员豁免配置-验证商户是独立商户-mch_member_exempt有数据");
		try {
//			createIndepMchBean createBean=GodmchManageCallService.InitCreateIndepMchBean();
//			createIndepMchCall createCall=GodmchManageCallService.CreateIndepMchCall(createBean);
			Integer mchId=500961860;
			bean.setMchId(mchId);
			bean.setMobile("18621212121");
			call.setData(bean);
			call.callService();			
			
//			memberExample.createCriteria().andMchIdEqualTo(mchId).andExemptStatusEqualTo(0);
//			List<mch_member_exemptExample> list=memberWapper.selectByExample(memberExample);
			
			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
			Logger.verifyEquals("请求成功", call.getMessage(), "验证Message");
			Logger.verifyEquals(true, call.getExemptEnabled(), "验证ExemptEnabled");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getMchMemberExemptConfig_001_1() {
		Logger.start(true,"查询商户会员豁免配置-验证商户是独立商户-mch_member_exempt有数据,但exempStatus=1");
		try {
			
			Integer mchId=500961887;
			bean.setMchId(mchId);
			bean.setMobile("18631313131");
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
			Logger.verifyEquals("请求成功", call.getMessage(), "验证Message");
			Logger.verifyEquals(false, call.getExemptEnabled(), "验证ExemptEnabled");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getMchMemberExemptConfig_001_2() {
		Logger.start(true,"查询商户会员豁免配置-验证商户是独立商户-mch_member_exempt无数据");
		try {
			
    		createIndepMchBean createBean=GodmchManageCallService.InitCreateIndepMchBean();
			createIndepMchCall createCall=GodmchManageCallService.CreateIndepMchCall(createBean);
			bean.setMchId(createCall.getmchId());
			bean.setMobile("18631313131");
			call.setData(bean);
			call.callService();			

			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
			Logger.verifyEquals("请求成功", call.getMessage(), "验证Message");
			Logger.verifyEquals(false, call.getExemptEnabled(), "验证ExemptEnabled");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getMchMemberExemptConfig_002() {
		Logger.start(true,"查询商户会员豁免配置-验证商户是平台商户");
		try {
			Integer mchId=GodmchManageCallService.CreateSellerMch();
			bean.setMobile("18641414141");
			bean.setMchId(mchId);
			call.setData(bean);
			call.callService();		
			
			Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
			Logger.verifyEquals("请求成功", call.getMessage(), "验证Message");
			Logger.verifyEquals(false, call.getExemptEnabled(), "验证ExemptEnabled");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getMchMemberExemptConfig_004() {
		Logger.start(true,"查询商户会员豁免配置-验证商户Id为空");
		try {
			
			bean.setMobile("18641414141");
		//	bean.setMchId(mchId);
			call.setData(bean);
			call.callService();		
			
			Logger.verifyEquals("4001", call.getStatusCode1(), "验证status");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getMchMemberExemptConfig_005() {
		Logger.start(true,"查询商户会员豁免配置-验证手机号为空");
		try {
			
    		createIndepMchBean createBean=GodmchManageCallService.InitCreateIndepMchBean();
			createIndepMchCall createCall=GodmchManageCallService.CreateIndepMchCall(createBean);
			bean.setMchId(createCall.getmchId());
			//bean.setMobile("18641414141");
			call.setData(bean);
			call.callService();		
			
			Logger.verifyEquals("4001", call.getStatusCode1(), "验证status");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}